#include <stdio.h>
#include <math.h>

int intPow(int a, int b) {
    int result = 1;
    for (int i = 0; i < b; i++) {
        result *= a;
    }
    return result;
}

int main(void) {
    while (1) {
        int a;
        scanf("%d", &a);
        if (a == 0) {
            break;
        }
        int base = 10000000;
        int result = 0;
        int len = -1;
        for(int i = 7; i >= 0; i--) {
            int digit = a / base % 10;
            if (len == -1 && digit != 0) {
                len = i + 1;
            }
            if (len != -1) {
                result += intPow(digit, len);
            }
            base /= 10;
        }
        puts(result == a ? "Yes" : "No");
    }
    return 0;
}
